package com.wen.yygh.common.util;

import com.wen.yygh.common.helper.JwtHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
@Slf4j
public class AuthContextHolder {

    public static Long getUserId(HttpServletRequest request) {
        //从请求头中获取token
        String token = request.getHeader("token");
        log.info("token"+token);
        //调用方法从token中获取userId
        Long userId = JwtHelper.getUserId(token);
        return userId;

    }

    public static String getUserName(HttpServletRequest request) {
        //从请求头中获取token
        String token = request.getHeader("token");
        //调用方法从token中获取userId
        String userName = JwtHelper.getUserName(token);
        return userName;

    }

}
